<?php
/**
 * Created by PhpStorm.
 * User: Lin
 * Date: 2017/2/9 0009
 * Time: 下午 16:09
 */

/**
 * 后台首页控制器
 */
Class IndexAction extends CommonAction
{

    //首页视图
    Public function index()
    {
        $this->display();
    }

    //退出登录
    Public function logout()
    {
        session_unset();
        session_destroy();
        $this->redirect(GROUP_NAME . '/Login/index');
    }

    //左侧菜单视图
    public function menu()
    {
        $nodeFunction = composite_node_id($_SESSION['_ACCESS_LIST']);
        $nodeAction = array_unique(M('node')->where(array('id' => array('IN', $nodeFunction)))->getField('pid', true));
        include(APP_PATH . 'Data/conf/menu_action.php');
        if ($_SESSION[C('ADMIN_AUTH_KEY')]) {//超级管理员显示所有菜单
            foreach ($modules AS $key => $val)//组合菜单数组
            {
                $menus[$key]['label'] = L("$key-1");
                if (is_array($val)) {
                    foreach ($val AS $k => $v) {
                        $menus[$key]['children'][$k]['label'] = L("$k-2");
                        $menus[$key]['children'][$k]['action'] = $v;
                    }
                }
            }
        } else {//过滤菜单
            foreach ($modules AS $key => $val)//组合菜单数组
            {
                if (in_array($key, $nodeAction)) {
                    $menus[$key]['label'] = L("$key-1");
                    if (is_array($val)) {
                        foreach ($val AS $k => $v) {
                            if (in_array($k, $nodeFunction)) {
                                $menus[$key]['children'][$k]['label'] = L("$k-2");
                                $menus[$key]['children'][$k]['action'] = $v;
                            }
                        }
                    }
                }
            }
        }
        $this->menus = $menus;
        $this->display();
    }

    //顶部视图
    public function top()
    {
        $this->display();
    }

    //伸缩视图
    public function drag()
    {
        $this->display();
    }

    //主体视图
    public function main()
    {
        $this->display();
    }

}